package com.kang;


import com.kang.commons.filter.CrossFilter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@SpringBootApplication(scanBasePackages = "com.kang.**")
@MapperScan(basePackages = "com.kang.mapper")
@EnableTransactionManagement //启动事务
@EnableDiscoveryClient //服务发现~
@EnableEurekaClient //本服务启动后胡自动注册进Eureka服务中
@EnableCircuitBreaker //
@EnableFeignClients
public class PleasureApp {
    public static void main(String[] args) {
        SpringApplication.run(PleasureApp.class,args);
    }

    @Bean
    public FilterRegistrationBean<CrossFilter> crossDomainFilter(){
        FilterRegistrationBean<CrossFilter> registrationBean =
                new FilterRegistrationBean<>();
        //web.xml中的filter
        registrationBean.setFilter(new CrossFilter());

        //web.xml 中的url-pattern
        registrationBean.addUrlPatterns("/*");
        return registrationBean;
    }
}
